package com.by.sbdemoby.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @auth wzy
 * @date 2023/12/2 10:45
 */
@Controller
// @Controller + @ResponseBody
public class HelloController {

    @GetMapping("/")
    @ResponseBody
    public String hello(HttpServletRequest request){
        return "Hello SB";
    }
    @GetMapping("/login")
    @ResponseBody
    public String login(HttpServletRequest request){
        int i=1/0;
        request.getSession().setAttribute("LoginUser","admin");
        return "登录成功";
    }

    @GetMapping("/logout")
    @ResponseBody
    public String logout(HttpServletRequest request){
        request.getSession().removeAttribute("LoginUser");
        return "登出成功";
    }

    @GetMapping("/index")
    public String index(){
        return "index";
    }
}
